The Window Resource
CHANGED WITH THE APPEARANCE MANAGER
You typically define a window ('WIND'
) resource for each type of window that your application creates. UseGetNewWindow
orGetNewCWindow
to create a window based on a'WIND'
resource. Both functions create a new window structure and fill it in according to the values specified in the'WIND'
resource.
Figure 3-2 illustrates a compiled
- Note
- Window resources must have resource ID numbers greater than 127.
![]()
'WIND'
resource.Figure 3-2 Structure of a compiled window
('WIND')
resource
A compiled version of a window resource contains the following elements:
- The upper-left and lower-right corners, in global coordinates, of a rectangle that defines the initial size and placement of the window's content region. Your application can change this rectangle before displaying the window, either programmatically or through an optional positioning code described later in this section.
- The window definition ID. The window definition ID is an integer that contains the resource ID of the window definition function in its upper 12 bits and a variation code in its lower 4 bits; see "Window Definition IDs" for a discussion of standard pre-Appearance and Appearance-compliant window definition IDs.
- A specification that determines whether the window will be visible or invisible. This characteristic controls only whether the Window Manager displays the window, not necessarily whether the window can be seen on the screen. (A visible window entirely covered by other windows, for example, is "visible" even though the user cannot see it.) You typically create a new window in an invisible state, build the content area of the window, and then display the completed window.
- A specification that determines whether or not the window will have a close box. The
'WDEF'
draws the close box when it draws the window frame. The window type specified in the second field determines whether a window can support a close box; this field determines whether the close box is present.- A reference constant, which your application can use for whatever data it needs to store. When it builds a new window structure, the Window Manager stores, in the
refCon
field, whatever value you specify in the fifth element of the window resource. You can also put a place-holder value here and then set therefCon
field programmatically with theSetWRefCon
function.- A pascal string that specifies the window title.
- A positioning specification that overrides the window position established by the rectangle in the first field. The existence of this field is optional. The positioning constants are convenient when the user is creating new documents or when you are handling your own dialog boxes and alert boxes. When you are creating a new window to display a previously saved document, however, you should display the new window in the same rectangle as that in which it was previously displayed.